package cn.git.bbs.core.service.sku;

import cn.git.bbs.core.bean.product.Sku;
import cn.git.bbs.core.bean.product.SkuQuery;
import cn.git.bbs.core.dao.product.ColorMapper;
import cn.git.bbs.core.dao.product.SkuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("skuService")
public class SkuServiceImpl implements SkuService {
    @Autowired
    private SkuMapper skuMapper;
    @Autowired
    private ColorMapper colorMapper;
    public List<Sku> selectSkuList(Long productId){
        SkuQuery skuQuery = new SkuQuery();
        skuQuery.createCriteria().andProductIdEqualTo(productId);
        List<Sku> skus = skuMapper.selectByExample(skuQuery);
        for (Sku  sku:skus) {
            sku.setColor(colorMapper.selectByPrimaryKey(sku.getColorId()));
        }
        return skus;
    }


}
